<template>
	<div class="g-state">{{text}}</div>
</template>

<script type="text/javascript">
import constant from '@/common/constant'
import remoteDAO from '@/common/remoteDAO'
// import tools from 'libs/common/tools'
import { destruct } from '@/common/common'

export default {
  name: 'state',
  data () {
    return {
      text: ''
    }
  },
  props: {
    type: {
      default: ''
    }
  },
  methods: {
    async fetch() {
      const res = await remoteDAO.invoke(constant.InterfaceEnum.GET_CAPI_STAT, { type: this.type });
//      let pm = res.TableInfo[0].je > 0;
//      this.text = `连续${res.TableInfo[0].days}日${pm ? '净流入' : '净流出'}，累计流${pm ? '入' : '出' + Math.abs(res.TableInfo[0].je)}`;
      const m = destruct(res.TableInfo[0].je);
      this.text = `连续${res.TableInfo[0].days}日${m.isNegative ? '净流出' : '净流入'}，
        累计${m.isNegative ? '流出' : '流入'}${m.num}${m.unit}`;
    }
  },
  mounted() {
    this.fetch();
  }
}
</script>

<style lang="less" scoped>
	@import '../../assets/css/variables.less';

	.g-state {
		background-color: @blue-e;
		color: white;
    font:.12rem/.25rem PingFangSC;
    height: .25rem;
    white-space: nowrap;
    overflow-x: auto;
	}
  ::-webkit-scrollbar{
    display:none;
  }
</style>
